package service.impl;

import Model.User;
import dao.UserDao;
import dao.impl.UserDaoImpl;
import service.UserService;

import java.sql.SQLException;
import java.util.ArrayList;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();

    @Override
    public User getUserByID(int id) throws SQLException {
        return userDao.getUserByID(id);
    }

    @Override
    public User getUserByName(String username) throws SQLException {
        return userDao.getUserByName(username);
    }

    @Override
    public ArrayList<User> getAllUser() throws SQLException {
        return userDao.getAllUser();
    }

    @Override
    public boolean doUpdate(User user) {
        return userDao.updateUser(user) == 1;
    }

    @Override
    public boolean doDelete(int id) {
        return userDao.deleteUser(id) == 1;
    }

    @Override
    public boolean addUser(User user) {
        return userDao.addUser(user) == 1;
    }
}
